//
// Decompiled by Jadx - 653ms
//
package me.plusne.Adapter.Login;

import android.app.Activity;
import android.text.TextUtils;
import androidx.activity.b;
import com.google.gson.Gson;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import fi.c;
import fi.e;
import fi.w;
import fi.y;
import gc.ay;
import gc.b;
import gc.bf;
import gc.cf;
import gc.cl;
import gj.c;
import gj.d;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import me.plusne.Adapter.Login.a;
import me.plusne.NativeTools;
import me.plusne.common.Http.Hook;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.JsonSetting;
import me.plusne.common.Json.Login.JsonLoginDeviceList;
import org.luckypray.dexkit.query.matchers.MethodMatcher;
import r.f;
import s.ah;
import s.ao;
import s.h;
import s.j;
import s.k;
import s.l;
import s.m;
import s.q;
import s.s;
import s.t;
import s.z;

public final class g implements w.g, w.b, w.c, w.f, a.a, w.e, m.a {
    public final int a;
    public final Object b;
    public final Object c;
    public final Object d;

    public g(Object obj, Object obj2, Object obj3, int i) {
        this.a = i;
        this.b = obj;
        this.c = obj2;
        this.d = obj3;
    }

    public final void e(String str, String str2) {
        int i = this.a;
        Object obj = this.d;
        Object obj2 = this.c;
        Object obj3 = this.b;
        switch (i) {
            case 8:
                Activity activity = (Activity) obj2;
                ((j) obj3).getClass();
                y.f(activity, "正在效验中...");
                p.a.e(str, str2, new h(activity, (m) obj));
                return;
            case 9:
                l lVar = (l) obj3;
                Activity activity2 = (Activity) obj2;
                lVar.getClass();
                y.f(activity2, "正在效验中...");
                p.a.e(str, str2, new k(lVar, activity2, (m) obj, activity2));
                return;
            case 10:
                s sVar = (s) obj3;
                Activity activity3 = (Activity) obj2;
                sVar.getClass();
                w wVar = new w(activity3);
                wVar.aj = "修改密码";
                wVar.bb();
                wVar.bj(fi.e.INPUT);
                wVar.ak = "输入新密码";
                wVar.bb();
                wVar.ap = false;
                wVar.r = "修改";
                wVar.bb();
                wVar.w = new q(activity3, str, str2, (m) obj, sVar);
                wVar.bk();
                return;
            case 11:
                z zVar = (z) obj3;
                Activity activity4 = (Activity) obj2;
                zVar.getClass();
                y.f(activity4, "正在效验中...");
                p.a.e(str, str2, new t(zVar, activity4, (m) obj));
                return;
            default:
                ao aoVar = (ao) obj3;
                Activity activity5 = (Activity) obj2;
                aoVar.getClass();
                y.f(activity5, "正在效验中...");
                p.a.e(str, str2, new ah(aoVar, activity5, (m) obj, activity5));
                return;
        }
    }

    /* JADX WARN: Failed to find 'out' block for switch in B:30:0x00e4. Please report as an issue. */
    public final void f(File file) {
        Iterator it;
        int i;
        long j;
        String as;
        String str;
        StringBuilder sb;
        String str2;
        StringBuilder sb2;
        String str3;
        StringBuilder sb3;
        List list = (List) this.c;
        String str4 = (String) this.d;
        String str5 = cf.cp;
        fn.y.co(file.getPath(), "SaveChatPath");
        Object obj = this.b;
        String as2 = fn.j.as(obj, "signature");
        String as3 = fn.j.as(obj, "alias");
        if (!TextUtils.isEmpty(as3) && !as3.equals(as2)) {
            as2 = as2 + "(" + as3 + ")";
        }
        Object ea = gc.z.ea();
        String as4 = fn.j.as(ea, "signature");
        StringBuilder sb4 = new StringBuilder("<html>\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\"/><meta charset=\"UTF-8\"><head>\n<style> \n.box{ margin:0 auto; width:auto; height:80px; border:0px solid #00F} \n</style>  \n</head>\n<body  style=\"background-color:#ECECEC;\">\n<div class=\"box\"> \n");
        String i2 = b.i("https://china-img.soulapp.cn/heads/", fn.j.as(obj, "avatarName"), ".png");
        String i3 = b.i("https://china-img.soulapp.cn/heads/", fn.j.as(ea, "avatarName"), ".png");
        Iterator it2 = list.iterator();
        char c = 0;
        int i4 = 0;
        while (it2.hasNext()) {
            Object next = it2.next();
            fn.j.as(next, "extMap");
            Class ak = fn.j.ak("cn.soulapp.imlib.msg.b");
            Object[] objArr = new Object[1];
            objArr[c] = next;
            Object ad = fn.j.ad(ak, "a", objArr);
            XposedHelpers.getIntField(ad, "isAck");
            long longField = XposedHelpers.getLongField(ad, "localTime");
            Object dr = gc.z.dr(ad);
            int intField = XposedHelpers.getIntField(dr, "msgType");
            Object obj2 = ((HashMap) XposedHelpers.getObjectField(dr, "maps")).get("MSGCONTENT");
            if (intField == 25) {
                c = 0;
            } else {
                if (intField != 1) {
                    if (intField != 2) {
                        it = it2;
                        if (intField == 4) {
                            i = i4;
                            j = longField;
                            XposedHelpers.getIntField(obj2, "height");
                            XposedHelpers.getIntField(obj2, "width");
                            String as5 = fn.j.as(obj2, "url");
                            sb2 = new StringBuilder("<object style=\"max-width: 100%;\"  data=\"");
                            sb2.append(as5);
                            str3 = "\"></object>";
                            StringBuilder sb5 = sb2;
                            str2 = str3;
                            sb = sb5;
                            sb.append(str2);
                            as = sb.toString();
                        } else if (intField == 5) {
                            i = i4;
                            j = longField;
                            as = "<a href=\"" + fn.j.as(obj2, "url") + "\">[语音文件 " + XposedHelpers.getIntField(obj2, "duration") + "s]</a>";
                        } else if (intField != 12) {
                            str2 = "]";
                            if (intField == 13) {
                                i = i4;
                                j = longField;
                                sb = b.l("[骰子游戏 - 点数", XposedHelpers.getIntField(obj2, "number"), "]");
                                as = sb.toString();
                            } else if (intField == 32) {
                                i = i4;
                                j = longField;
                                as = "[分享的瞬间,暂不支持查看]";
                            } else if (intField != 33) {
                                if (intField != 35) {
                                    switch (intField) {
                                        case 8:
                                            break;
                                        case 9:
                                            as = "[对方撤回了一条消息]";
                                            i = i4;
                                            j = longField;
                                            break;
                                        case 10:
                                            sb3 = new StringBuilder("[对方分享了一位Souler] ID: ");
                                            sb3.append(fn.j.as(obj2, "userId"));
                                            sb3.append(" name:");
                                            str2 = fn.j.as(obj2, "userSignature");
                                            break;
                                        default:
                                            as = "";
                                            i = i4;
                                            j = longField;
                                            break;
                                    }
                                } else {
                                    sb3 = new StringBuilder("[当前不支持查看此消息- ");
                                    sb3.append(fn.j.as(obj2, "messageType"));
                                }
                                sb3.append(str2);
                                as = sb3.toString();
                                i = i4;
                                j = longField;
                            } else {
                                sb = new StringBuilder("[位置信息:");
                                sb.append(fn.j.as(obj2, "address"));
                                sb.append(" lat:");
                                i = i4;
                                j = longField;
                                sb.append(XposedHelpers.getDoubleField(obj2, "lat"));
                                sb.append(" lng:");
                                sb.append(XposedHelpers.getDoubleField(obj2, "lng"));
                                sb.append(str2);
                                as = sb.toString();
                            }
                        } else {
                            i = i4;
                            j = longField;
                            int intField2 = XposedHelpers.getIntField(obj2, "number");
                            as = intField2 != 2 ? intField2 != 3 ? "[石头剪刀布游戏 - 布]" : "[石头剪刀布游戏 - 石头]" : "[石头剪刀布游戏 - 剪刀]";
                        }
                    } else {
                        it = it2;
                    }
                    i = i4;
                    j = longField;
                    XposedHelpers.getIntField(obj2, "imageH");
                    XposedHelpers.getIntField(obj2, "imageW");
                    String as6 = fn.j.as(obj2, "imageUrl");
                    sb2 = new StringBuilder("<img style=\"max-width: 100%;\"  src=\"");
                    sb2.append(as6);
                    str3 = "\" alt=\"PlusNEImage\" >";
                    StringBuilder sb52 = sb2;
                    str2 = str3;
                    sb = sb52;
                    sb.append(str2);
                    as = sb.toString();
                } else {
                    it = it2;
                    i = i4;
                    j = longField;
                    as = fn.j.as(obj2, "text");
                }
                if (TextUtils.isEmpty(as)) {
                    c = 0;
                    fn.j.bi(new Object[]{b.e("msgType", intField)});
                    fn.j.bh(obj2);
                } else {
                    if (!Objects.equals(fn.j.as(ad, "from"), gc.z.eb())) {
                        sb4.append("  <section style=\"margin-right:auto;margin-left:auto;clear:both;position:relative;width:100%;overflow:hidden;\" data-width=\"100%\">\n   <section style=\"margin-top:0.5em;margin-bottom:0.5em;position:static;display:flex;\">\n    <section style=\"display: inline-block; vertical-align: top; width:60px;\">\n     <section style=\"text-align: left; position: static;\">\n      <img src=\"");
                        sb4.append(i2);
                        sb4.append("\" style=\"vertical-align: middle;width: 60px;border-radius: 50%;\" />\n     </section>\n    </section>\n    <section style=\"padding-right:10px;padding-left:10px;box-sizing:border-box;display:inline-block;vertical-align:top;flex:0 0 80%;\">\n     <section style=\"padding-left:1em;box-sizing:border-box;\">\n      <p style=\"display:inline-block;font-size:12px;\">");
                        sb4.append(as2);
                        sb4.append("&nbsp;");
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        Date date = r.h.a;
                        sb4.append(r.h.g(new Date(j), simpleDateFormat));
                        sb4.append("</p>\n     </section>\n     <section style=\"position:static;display:flex;justify-content:flex-start;\">\n      <section style=\"margin-top:1em;width:0px;height:0px;border-right-width:10px;border-right-style:solid;border-right-color:rgb(254,254,254);display:inline-block;vertical-align:top;border-top-width:6px !important;border-top-style:solid !important;border-top-color:transparent !important;border-bottom-width:6px !important;border-bottom-style:solid !important;border-bottom-color:transparent !important;\"></section>\n      <section style=\"padding:0px 10px;font-size:14px;box-sizing:border-box;display:inline-block;vertical-align:middle;border-radius:0.5em;color:rgb(0,0,0);background-color:rgb(254,254,254);\">\n       <p style=\"font-size:14px;\">");
                        sb4.append(as);
                        str = "</p>\n      </section>\n     </section>\n    </section>\n   </section>\n  </section>\n";
                    } else {
                        sb4.append("  <section style=\"margin-right: auto; margin-left: auto; clear: both; position: relative; overflow: hidden;\">\n   <section style=\"display:flex; display:-webkit-flex; justify-content:flex-end; -webkit-justify-content:flex-end;\">\n    <section style=\"padding-right: 10px; padding-left: 10px;box-sizing:border-box; display: inline-block; vertical-align: top; text-align: right;\">\n     <section style=\"padding-right: 1em;box-sizing:border-box; position: static;\">\n      <p style=\"display: inline-block; font-size: 12px;\">");
                        sb4.append(as4);
                        sb4.append("&nbsp;");
                        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        Date date2 = r.h.a;
                        sb4.append(r.h.g(new Date(j), simpleDateFormat2));
                        sb4.append("</p>\n     </section>\n     <section style=\"position: static;display:flex;\ndisplay:-webkit-flex;justify-content: flex-end; -webkit-justify-content: flex-end;\">\n      <section style=\"text-align: left;font-size:14px;box-sizing:border-box;padding: 0px 10px;display: inline-block;vertical-align: middle;border-radius: 0.5em;color: rgb(0, 0, 0);background-color: rgb(150,236,103);\">\n       <p>");
                        sb4.append(as);
                        sb4.append("</p>\n      </section>\n      <section style=\"margin-top: 1em;width: 0px;border-left-width: 10px;border-left-style: solid;border-left-color: rgb(150,236,103);display: inline-block;vertical-align: top;border-top-width: 6px !important;border-top-style: solid !important;border-top-color: transparent !important;border-bottom-width: 6px !important;border-bottom-style: solid !important;border-bottom-color: transparent !important;height: 0px;\"></section>\n     </section>\n    </section>\n    <section style=\"display: inline-block; vertical-align: top; width:60px;\">\n     <section style=\"text-align: left; position: static;\">\n      <img src=\"");
                        sb4.append(i3);
                        str = "\" style=\"vertical-align: middle;width: 60px;border-radius: 50%;\" />\n     </section>\n    </section>\n   </section>\n  </section>\n";
                    }
                    sb4.append(str);
                    c = 0;
                }
                i4 = i + 1;
                it2 = it;
            }
        }
        int i5 = i4;
        sb4.append("</div>\n</body>\n</html>");
        if (!file.exists()) {
            file.mkdir();
        }
        File file2 = new File(file.getPath(), "SoulChat_NE_" + gc.z.eb() + "_" + str4 + "_" + i5 + ".html");
        try {
            String str6 = new String(sb4.toString().getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
            try {
                FileWriter fileWriter = new FileWriter(file2);
                fileWriter.write(str6);
                fileWriter.flush();
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            w wVar = new w(fn.y.by.getActivity());
            wVar.bj(fi.e.MESSAGE);
            wVar.aj = "导出成功 " + i5 + " 条";
            wVar.bb();
            wVar.ak = "导出路径:\n" + file2.getPath() + "\n是否浏览器查看效果(如果文件不存在,请选择导出目录为DownLoad)";
            wVar.bb();
            wVar.r = "浏览器查看";
            wVar.bb();
            wVar.v = new fi.k(12, file2);
            wVar.bk();
        } catch (Exception e2) {
            f i6 = f.i();
            i6.j();
            i6.d = 17;
            i6.l("导出失败:" + e2.getMessage());
        }
    }

    public final void g(w wVar, boolean z) {
        c cVar = (c) this.b;
        String str = (String) this.c;
        String str2 = (String) this.d;
        if (z) {
            d dVar = cVar.d;
            y.e(dVar.b);
            androidx.appcompat.app.t.c().j(((Hook) dq.b.b(Hook.class)).autoRedeem(str, str2).subscribeWith(new c.a(cVar, dVar.b)));
            return;
        }
        cVar.getClass();
    }

    public final void h(String str, String str2, w wVar, boolean z) {
        f fVar;
        String str3;
        int i = this.a;
        Object obj = this.d;
        Object obj2 = this.c;
        Object obj3 = this.b;
        switch (i) {
            case 1:
                b.a aVar = (b.a) obj3;
                XC_MethodHook.MethodHookParam methodHookParam = (XC_MethodHook.MethodHookParam) obj2;
                String str4 = (String) obj;
                int i2 = b.a.a;
                aVar.getClass();
                if (z) {
                    fn.j.bn(methodHookParam.args[2], "extAttributes", str);
                    gc.b.cq(aVar.b, new Gson().toJson(methodHookParam.args[2]), str4);
                    return;
                }
                return;
            case 2:
                ay ayVar = (ay) obj3;
                String str5 = (String) obj2;
                int i3 = ay.a;
                ayVar.getClass();
                if (z) {
                    Object aa = fn.j.aa(fn.j.aa(fn.j.ab(gc.z.ee(), gc.z.cu.getMethodName(), new Object[]{fn.j.bk(XposedHelpers.findMethodExact(fn.j.ak("io.objectbox.EntityInfo"), "getIdProperty", new Class[0]).getReturnType(), new Object[]{fn.j.bk(fn.j.ak("cn.soulapp.imlib.database.ChatMsgDb_"), new Object[0]), 1, 2, String.class, "msgId"}), str5, fn.j.ak("io.objectbox.query.QueryBuilder.StringOrder").getEnumConstants()[0]}), gc.z.cv.getMethodName()), gc.z.cx.getMethodName());
                    fn.j.bn(obj, "text", str);
                    Object ad = fn.j.ad(gc.z.ds(), "a", new Object[]{ayVar.b.ct});
                    XposedHelpers.setLongField(ad, "id", XposedHelpers.getLongField(aa, "id"));
                    Object ed = gc.z.ed();
                    if (fn.j.ab(ed, fo.c.r(MethodMatcher.create().declaredClass(ed.getClass()).returnType(Long.TYPE).paramTypes(new Class[]{Object.class})).getMethodName(), new Object[]{ad}) == null) {
                        androidx.activity.b.u("修改失败");
                        return;
                    }
                    JsonHookStatic jsonHookStatic = fn.y.by;
                    if (jsonHookStatic.getSoul().getBaseConversationFragment() != null) {
                        fn.j.aa(jsonHookStatic.getSoul().getBaseConversationFragment(), "onRefreshUi");
                        return;
                    }
                    return;
                }
                return;
            default:
                gj.k kVar = (gj.k) obj3;
                List list = (List) obj2;
                String str6 = (String) obj;
                kVar.getClass();
                if (z) {
                    JsonSetting jsonSetting = new JsonSetting();
                    jsonSetting.setSetting(new Gson().toJson(list));
                    jsonSetting.setSign(NativeTools.k(jsonSetting.getSetting()));
                    boolean g = fj.d.g(str6 + str + ".pn", new Gson().toJson(jsonSetting));
                    Activity activity = kVar.d;
                    if (g) {
                        fVar = new f(activity);
                        fVar.d = 80;
                        fVar.n();
                        str3 = "已导出设置项:\n" + str6 + str + ".pn";
                    } else {
                        fVar = new f(activity);
                        fVar.d = 80;
                        fVar.j();
                        str3 = "导出失败";
                    }
                    fVar.l(str3);
                    return;
                }
                return;
        }
    }

    public final void i(w wVar, c.a aVar, int i, int i2) {
        int i3 = this.a;
        Object obj = this.d;
        Object obj2 = this.c;
        Object obj3 = this.b;
        switch (i3) {
            case 3:
                String str = (String) obj2;
                XC_MethodHook.MethodHookParam methodHookParam = (XC_MethodHook.MethodHookParam) obj;
                String str2 = bf.cp;
                ((bf) obj3).getClass();
                if (aVar.getTitle().equals("清除本地字母")) {
                    fn.b.c(9, str);
                } else {
                    fn.b.k(str, 9, aVar.getTitle(), "");
                }
                bf.cr(methodHookParam.thisObject);
                wVar.c.dismiss();
                return;
            default:
                ao aoVar = (ao) obj3;
                aoVar.getClass();
                ((cc.b) obj2).a.setText(aVar.getTitle() + aVar.getDesc());
                aoVar.f = aVar.getTitle();
                ((w) obj).az();
                return;
        }
    }

    public final void j(boolean z, JsonLoginDeviceList.DataBean dataBean, int i) {
        gj.b bVar = (gj.b) this.b;
        String str = (String) this.c;
        String str2 = (String) this.d;
        d dVar = bVar.d;
        if (z) {
            w wVar = new w(dVar.b);
            wVar.bj(fi.e.INPUT);
            wVar.aj = "设备位名称修改";
            wVar.bb();
            wVar.k = dataBean.getName();
            wVar.ag = "输入您想设置的自定义名称";
            wVar.r = "修改";
            wVar.bb();
            wVar.ap = false;
            wVar.w = new cl(bVar, str, str2, dataBean, i);
            wVar.bk();
            return;
        }
        String uuid = dataBean.getUuid();
        Activity activity = dVar.b;
        y.e(activity);
        androidx.appcompat.app.t.c().j(((Hook) dq.b.b(Hook.class)).login(str, str2, uuid).subscribeWith(new gj.c(dVar, activity, str, str2)));
    }
}
